/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-09-21
 * Time: 17:24
 */
//等待线程
public class Demo9 {
    public static void main(String[] args) {
        Thread b=new Thread(() ->{
            for (int i = 0; i <10; i++) {
                System.out.println("b");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("b 结束");
        });

        Thread a=new Thread(() ->{
            for (int i = 0; i <15; i++) {
                System.out.println(" a ");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            try {
                //b还没有执行完毕，执行这个语句，b会产生阻塞的情况
                b.join(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("a 结束");
        });

        b.start();
        a.start();
    }
}
